import Vue from 'vue'
import Vuex from 'vuex'
import { auInfo } from '@/api/my'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo: '', // 用户信息
    isLogin: false // 是否登录
    // findArr: []
    // redirectPath: ''
  },
  mutations: {
    setUserInfo (state, value) {
      state.userInfo = value
    },
    setIsLogin (state, value) {
      state.isLogin = value
    }
    // setFindArr (state, value) {
    //   state.findArr = value
    // }
    // setRedirectPath (state, value) {
    //   state.redirectPath = value
    // }
  },
  actions: {
    // 刷新用户信息
    async refreshUserInfo (store) {
      const res = await auInfo()
      store.commit('setUserInfo', res.data.data)
    }
    // this.$store.dispatch("refreshUserInfo")
  },
  modules: {}
})
